package com.manage;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class Class {
    private int id;
    private String name;
    private List<Group> groups;
    private List<Student> students;

    public Class(int id, String name) {
        this.id = id;
        this.name = name;
        this.groups = new ArrayList<>();
        this.students = new ArrayList<>();
    }

    // 班级管理方法
    public void addStudent(Student student) {
        students.add(student);
    }

    public void removeStudent(Student student) {
        students.remove(student);
    }

    public void addGroup(Group group) {
        groups.add(group);
    }

    public void removeGroup(Group group) {
        groups.remove(group);
    }

    // 随机点名方法
    public Student getRandomStudent() {
        if (students.isEmpty()) return null;
        Random random = new Random();
        return students.get(random.nextInt(students.size()));
    }

    public Group getRandomGroup() {
        if (groups.isEmpty()) return null;
        Random random = new Random();
        return groups.get(random.nextInt(groups.size()));
    }

    // Getters and Setters
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public List<Group> getGroups() {
        return groups;
    }

    public List<Student> getStudents() {
        return students;
    }
}
